# -*- coding: utf-8 -*-
import urllib.request
import os
gostPath = os.environ.get('USERPROFILE') + "\gost.exe"
if os.path.exists(gostPath) is False:
    print("文件不存在，开始下载")
    try:
        urllib.request.urlretrieve("http://seth.oss-cn-shanghai.aliyuncs.com/gost.exe", gostPath)
        print("下载成功，保存位置%s" % gostPath)
    except  Exception as e:
        print("下载失败%s" % e)
else:
    print("文件已存在")
content=("""DIM objShell
set objShell=wscript.createObject("wscript.shell")  
iReturn=objShell.Run("cmd.exe /C %s -L=:%s -F=%s", 0, TRUE)
""" % (gostPath, 8089, "mwss://admin:40091217@seth-blog3-bwlab.c9users.io:8081"))
print("开机自启动脚本内容\n%s" % content)
startPath=os.environ.get('APPDATA')+"\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\startGost.vbs"
print("开机自启动脚本保存位置%s" % startPath)
f=open(startPath,  'w')
f.write(content)
f.close()
desktopPath = os.environ.get('USERPROFILE') + "\Desktop\\startGost.vbs"
print("脚本保存桌面startGost.vbs,请手动启动")
f=open(desktopPath,  'w')
f.write(content)
f.close()
input('按回车键退出')
